IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'CreatorSetRoleForSaga')
	BEGIN
		DROP  Procedure  CreatorSetRoleForSaga
	END

GO

CREATE Procedure CreatorSetRoleForSaga
@CreatorID Int,
@SagaID TinyInt,
@SagaRoleID TinyInt
AS
If NOT EXISTS( Select CreatorID From SagaCreators Where CreatorID=@CreatorID And SagaID=@SagaID)
BEGIN
Insert Into SagaCreators
(CreatorID,SagaID,SagaRoleID)
Values
(@CreatorID,@SagaID,@SagaRoleID)
END
ELSE
BEGIN 
Update SagaCreators
Set SagaRoleID = @SagaRoleID
Where CreatorID = @CreatorID And SagaID = @SagaID 
END
GO


